//
//  LWVistorView.swift
//  MicroBlog
//
//  Created by 孙程 on 2017/7/17.
//  Copyright © 2017年 孙程. All rights reserved.
//

import UIKit

//访客视图
class LWVistorView: UIView {
    
    //懒加载控件
    //旋转视图
    private lazy var cycleImageView:UIImageView = UIImageView(image: UIImage(named: "visitordiscover_feed_image_smallicon"))
    //罩层
    private lazy var maskImageView:UIImageView = UIImageView(image: UIImage(named:"visitordiscover_feed_mask_smallicon"))
    //小房子
    private lazy var houseImageView:UIImageView = UIImageView(image: UIImage(named:"visitordiscover_feed_image_house"))
    //未登录信息视图
    private lazy var messageLabel:UILabel = {
        let label = UILabel()
        label.text = "关注一些人，回头看看有什么惊喜 关注一些人， 回头看看有什么惊喜"
        label.font = UIFont .systemFont(ofSize: 13)
        label.textColor = UIColor.darkGray
        label.textAlignment = .center
        //设置多行显示
        label.numberOfLines = 0
        
        return label
    }()
    //登录按钮
    private lazy var logInBtn:UIButton = {
        let button = UIButton()
        button .setTitle("登录", for: .normal)
        button .setTitleColor(UIColor.darkGray, for: .normal)
        button .setTitleColor(UIColor.orange, for: .highlighted)
        button.titleLabel?.font = UIFont .systemFont(ofSize: 14)
        button.adjustsImageWhenHighlighted = false
        button .setBackgroundImage(UIImage(named:"common_button_white_disable"), for: .normal)
        return button
    }()
    
    //注册按钮
    private lazy var registerBtn:UIButton = {
        let button = UIButton()
        button .setTitle("注册", for: .normal)
        button .setTitleColor(UIColor.darkGray, for: .normal)
        button .setTitleColor(UIColor.orange, for: .highlighted)
        button.titleLabel?.font = UIFont .systemFont(ofSize: 14)
        button.adjustsImageWhenHighlighted = false
        button .setBackgroundImage(UIImage(named:"common_button_white_disable"), for: .normal)
        return button
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI(){
        backgroundColor = UIColor(white: 237/255, alpha: 1)
        
        addSubview(cycleImageView)
        addSubview(maskImageView)
        addSubview(houseImageView)
        addSubview(messageLabel)
        addSubview(logInBtn)
        addSubview(registerBtn)
        
        cycleImageView .snp_makeConstraints { (make) in
            make.center.equalTo(self)
        }
        maskImageView .snp_makeConstraints { (make) in
            make.center.equalTo(cycleImageView)
        }
        houseImageView .snp_makeConstraints { (make) in
            make.center.equalTo(cycleImageView)
        }
        messageLabel .snp_makeConstraints { (make) in
            make.centerX.equalTo(cycleImageView)
            make.top.equalTo(cycleImageView.snp_bottom)
            make.width.equalTo(224)
        }
        logInBtn .snp_makeConstraints { (make) in
            make.leading.equalTo(messageLabel.snp_leading)
            make.top.equalTo(messageLabel.snp_bottom).offset(10)
            make.size.equalTo(CGSize(width: 100, height: 35))
        }
        registerBtn .snp_makeConstraints { (make) in
            make.trailing.equalTo(messageLabel.snp_trailing)
            make.top.equalTo(messageLabel.snp_bottom).offset(10)
            make.size.equalTo(CGSize(width: 100, height: 35))
        }
        
        
//        //使用系统自动布局
//        cycleImageView.translatesAutoresizingMaskIntoConstraints = false
//        
//        //设置约束
        //修改访客视图信息
       }
    func updataVistorInfo(message:String?,imageName:String?){
        
        if let msage = message,let imgN = imageName {
            
            messageLabel.text = msage
            houseImageView.image = UIImage(named: imgN)
            cycleImageView.isHidden = true
        }else
        {
            //执行旋转动画
            
        }
        
        
        
    }

    
}
